package com.lmk;

import java.util.ArrayList;
import java.util.Scanner;

public class CustomerTest {
    public static void main(String[] args) {
        ArrayList<Administrator> users = new ArrayList<>();
        Administrator user;

        Scanner sc = new Scanner(System.in);
        int choose = -1;

        do{
            System.out.println("1.添加管理员，2.修改管理员信息, 0.退出");
            System.out.print("请选择：");
            choose = sc.nextInt();

            switch (choose){
                case 1:
                    user = new Administrator();

                    System.out.print("请输入用户名：");
                    user.username = sc.next();
                    System.out.print("请输入密码：");
                    user.password = sc.next();

                    users.add(user);
                    break;
                case 2:
                    for (int i = 0; i < users.size(); i++) {
                        user = users.get(i);
                        System.out.println(i + ".\t" + user.username + "\t\t" + user.password);
                    }
                    System.out.print("请输入用户编号：");

                    user = users.get(sc.nextInt());
                    System.out.print("请输入新的密码：");
                    user.password = sc.next();
                    System.out.println("修改成功！");
                    break;
            }
        }while (choose != 0);

        System.out.println("感谢您的使用");
    }
}
